package com.cloud.feign.controller;

import com.cloud.feign.bean.User;
import com.cloud.feign.service.FeignClient1;
import com.cloud.feign.service.FeignClient2;
import com.cloud.feign.service.FeignClient3;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: myboots
 * @description:
 * @author: Mr.Zou
 * @create: 2019-08-13 18:13
 **/
@Slf4j
@RestController
public class FeginController {

    @Autowired
    private FeignClient1 feignClient1;
    @Autowired
    private FeignClient2 feignClient2;
    @Autowired
    private FeignClient3 feignClient3;


    @GetMapping(value = "/hi/{name}")
    public String sayHi(@PathVariable(value = "name") String name) {
        return feignClient1.sayHiFromClientOne(name);
    }

    @GetMapping(value = "/hi2/{name}")
    public String sayHi2(@PathVariable(value = "name") String name) {
        return feignClient2.sayHi(name);
    }

    @PostMapping(value = "/user")
    public User getUser() {
        User user = new User(1001,"混世魔王");
        return feignClient1.getUser(user);
    }

    @GetMapping(value = "/getList")
    public List<User> getList(){
        return feignClient1.getList();
    }


    @GetMapping("/getServer/{serviceName}")
    public String getServiceInfo(@PathVariable(name = "serviceName") String serviceName) {
        return feignClient3.getServiceInfo(serviceName);
    }

}



